package fr.mobile2you.golfplus.gui.common;

import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.LabelField;

public class CustomLabelField extends LabelField {
	private int color;

	public CustomLabelField() {
		super();
	}

	public CustomLabelField(Object text) {
		super(text);
	}

	public CustomLabelField(Object text, long style) {
		super(text, style);
	}

	public CustomLabelField(Object text, int color) {
		super(text);
		this.color = color;
	}

	public CustomLabelField(Object text, int color, Font font) {
		super(text);
		this.color = color;
		super.setFont(font);
	}

	public CustomLabelField(Object text, long style, int color) {
		super(text, style);
		this.color = color;
	}

	public CustomLabelField(Object text, long style, Font font) {
		super(text, style);
		super.setFont(font);
	}

	public CustomLabelField(Object text, long style, int color, Font font) {
		super(text, style);
		super.setFont(font);
		this.color = color;
	}

	public void paint(Graphics g) {
		g.setColor(color);
		super.paint(g);
	}

	private int width = 0;

	public void setWidth(int width) {
		this.width = width;
		setExtent(width, getHeight());
	}

	public int getPreferredWidth() {
		return Math.max(width, super.getPreferredWidth());
	}

	protected void layout(int width, int height) {
		width = Math.min(getPreferredWidth(), width);
		super.layout(width, height);
	}
}
